export class PlatformHelper {
    public static detectPlatform(): string {
        let userAgent = navigator.userAgent ? navigator.userAgent.toLowerCase() : "";
        if (userAgent.indexOf("micromessenger") != -1 && userAgent.indexOf("wxwork") != -1) {
            return PlatformName.wxWork;
        } else if (userAgent.indexOf("micromessenger") != -1) {
            return PlatformName.weChat;
        } else if (userAgent.indexOf("android") != -1) {
            return PlatformName.android;
        } else if (userAgent.indexOf("iphone") != -1 || userAgent.indexOf("ipad") != -1) {
            return PlatformName.ios;
        }

        return "";
    }

  static isMobileMode(): boolean {
    let isLandscape = window.matchMedia(`(max-width: 1000px) and (orientation: landscape)`).matches;
    let isPortrait = window.matchMedia(`(max-width: 576px) and (orientation: portrait)`).matches;
    return isLandscape || isPortrait;
  }
}

export class PlatformName {
    public static readonly weChat = "wechat";
    //企业微信
    public static readonly wxWork = "wxwork";
    public static readonly android = "android";
    public static readonly ios = "ios";
}
